
/**
 * 以函数的方式自定义模拟数据模板
 *
 * @module mock/templates
 *
 * @example 模板定义方法
 *
 * export function templateFuncName(Mock, url, query) {
 *    return {code:0, data:[], msg: ''}
 * }
 *
 */
import Mock from 'mockjs'
const Random = Mock.Random

const getSourceListMock = function(Mock, url, query) {
  return Mock.mock({
    code: 0,
    msg: '',
    data: [
      {
        'id': 10083,
        'indexName': 'jxz_st_zsryb',
        'boost': 0,
        'remark': '自杀人员',
        'screagrade': 0,
        'createtime': '2019-03-05 02:20:37',
        'url': '/jxzStZsryb',
        'columns': `{
          "tableComment": "自杀人员信息",
          "list": [
            {"columnComment": "自杀人员ID", "attrname": "zsryid"},
            {"columnComment": "姓名", "attrname": "xm"},
            {"columnComment": "性别", "attrname": "xb"},
            {"columnComment": "年龄", "attrname": "nl"}
          ]
        }`,
        'total|0-99': 1
      }
      // {
      //   'id': 10089,
      //   'indexName': 'sys_user',
      //   'boost': 0,
      //   'remark': '系统用户',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:36:34',
      //   'url': '/sysUser',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10090,
      //   'indexName': 't_zczhf_zhengshu_info',
      //   'boost': 0,
      //   'remark': '侦查证',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 03:38:00',
      //   'url': '/tZczhfZhengshuInfo',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10086,
      //   'indexName': 't_jdyq_resultxx',
      //   'boost': 0,
      //   'remark': '营区核查_核查结果',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:32:58',
      //   'url': '/jdyqResultxx',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10085,
      //   'indexName': 'dak_ryjbxx_task_log',
      //   'boost': 0,
      //   'remark': '背景审查记录',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:32:47',
      //   'url': '/dakRyjbxxTaskLog',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10082,
      //   'indexName': 'jxz_st_xsaj',
      //   'boost': 0,
      //   'remark': '刑事案件',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:20:37',
      //   'url': '/jxzStXsaj',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10088,
      //   'indexName': 'sys_organ',
      //   'boost': 0,
      //   'remark': '单位',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:36:34',
      //   'url': '/sysOrgan',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10084,
      //   'indexName': 'dak_ryjbxx',
      //   'boost': 0,
      //   'remark': '人员基本信息',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:32:39',
      //   'url': '/dakRyjbxx',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
      //   'total|0-99': 1
      // },
      // {
      //   'id': 10087,
      //   'indexName': 't_jdyq_rysmdjxx',
      //   'boost': 0,
      //   'remark': '营区核查_人员',
      //   'screagrade': 0,
      //   'createtime': '2019-03-05 02:34:20',
      //   'url': '/jdyqRysmdjxx',
      //   'columns': `{
      //     'tableComment': '自杀人员信息',
      //     'list': [
      //       {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
      //       {'columnComment': '姓名', 'attrname': 'xm'},
      //       {'columnComment': '性别', 'attrname': 'xb'},
      //       {'columnComment': '年龄', 'attrname': 'nl'}
      //     ]
      //   }`,
       
      //   'total|0-99': 1
      // }
    ]
  })
}

function INFOLIST(size, q) {
  let arr = []
  for (let index = 0; index < size - 1; index++) {
    let obj = {}
    // {'columnComment': '自杀人员ID', 'attrname': 'zsryid'},
    // {'columnComment': '姓名', 'attrname': 'xm'},
    // {'columnComment': '性别', 'attrname': 'xb'},
    // {'columnComment': '年龄', 'attrname': 'nl'}
    obj.xm = Random.cname()
    obj.xb = '男'
    obj.nl = Math.round(Math.random() * (70 - 20))
    obj.zsryid = Random.id()
   
    arr.push(obj)
  }
  arr = arr.concat([{
    xm: '黄吉平',
    xb: '男',
    nl: Math.round(Math.random() * (70 - 20)),
    zsryid: 15914375662
  }])
  return arr
}
Random.extend({
  infoList: function(size, q) {
    return INFOLIST(size, q)
  }
})

/*
<span class="col"><em>采集时间</em><strong>2018-10-01</strong></span>
<span class="col"><em>采集</em><strong>自动采集</strong></span>
<span class="col"><em>姓名</em><strong>{{scope.row.data.name}}</strong></span>
<span class="col"><em>军官证号</em><strong>0700107</strong></span>
<span class="col"><em>单位名称</em><strong>北京市</strong></span>
<span class="col"><em>曾用名</em><strong>张三无</strong></span>
<span class="col"><em>别名</em><strong>校长</strong></span>
<span class="col"><em>身份证</em><strong>440104197806215656</strong></span>

"columns": {
  "tableComment":"自杀人员信息",
  "list":[
    {"columnComment":"自杀人员ID","attrname":"zsryid"},
    {"columnComment":"姓名","attrname":"xm"},
    {"columnComment":"性别","attrname":"xb"},
    {"columnComment":"年龄","attrname":"nl"},
    {"columnComment":"单位","attrname":"dw"},
    {"columnComment":"职务","attrname":"zw"},
    {"columnComment":"军衔","attrname":"jx"},
    {"columnComment":"入伍时间","attrname":"rwsj"},
    {"columnComment":"民族","attrname":"mz"},
    {"columnComment":"籍贯","attrname":"jg"},
    {"columnComment":"自杀方式","attrname":"zsfs"},
    {"columnComment":"政治面貌","attrname":"zzmm"},
    {"columnComment":"审批标识","attrname":"spbz"},
    {"columnComment":"审批状态","attrname":"spzt"},
    {"columnComment":"死亡情况","attrname":"swqk"},
    {"columnComment":"发现单位","attrname":"fxdw"},
    {"columnComment":"报案号","attrname":"bah"},
    {"columnComment":"发现地点","attrname":"fxdd"},
    {"columnComment":"自杀时间","attrname":"zssj"},
    {"columnComment":"发现时间","attrname":"fxsj"},
    {"columnComment":"受伤情况","attrname":"ssqk"},
    {"columnComment":"案件来源","attrname":"ly"},
    {"columnComment":"简要情况","attrname":"jyqk"},
    {"columnComment":"自杀动机","attrname":"zsdj"},
    {"columnComment":"人员类别","attrname":"rylb"},
    {"columnComment":"文化","attrname":"wh"},
    {"columnComment":"证件号","attrname":"zjh"},
    {"columnComment":"手机号","attrname":"sjh"},
    {"columnComment":"审核人","attrname":"shr"},
    {"columnComment":"填表人","attrname":"tbr"},
    {"columnComment":"填报时间","attrname":"tbsj"},
    {"columnComment":"备注","attrname":"bz"},
    {"columnComment":"大单位","attrname":"ddw"},
    {"columnComment":"相关附件","attrname":"xgfj"},
    {"columnComment":"案件名称","attrname":"ajmc"},
    {"columnComment":"创建人","attrname":"cjr"},
    {"columnComment":"创建单位","attrname":"cjdw"},
    {"columnComment":"创建时间","attrname":"cjsj"},
    {"columnComment":"职级","attrname":"zj"},
    {"columnComment":"创建时间","attrname":"createdtime"},
    {"columnComment":"自杀城市","attrname":"zscs"}
  ]
*/

const getInfoListMock = function(Mock, url, query) {
  return Mock.mock({
    code: 0,
    msg: '',
    data: {
      page: `${query.page}`,
      limit: `${query.size}`,
      total: 50,
      content: `@infoList(${query.size}, ${decodeURIComponent(query.q)})`
      // [`list|${query.size}`]: `@infoList(${query.size})`
    }
  })
}

export function getSourceList(Mock, url, query) {
  return getSourceListMock(Mock, url, query)
}

export function getInfoList(Mock, url, query) {
  return getInfoListMock(Mock, url, query)
}
